/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gmao.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Amine
 */
@Entity
@Table(name = "intervention")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Intervention.findAll", query = "SELECT i FROM Intervention i"),
    @NamedQuery(name = "Intervention.findByDateIntervention", query = "SELECT i FROM Intervention i WHERE i.dateIntervention = :dateIntervention"),
    @NamedQuery(name = "Intervention.findByDureeIntervention", query = "SELECT i FROM Intervention i WHERE i.dureeIntervention = :dureeIntervention"),
    @NamedQuery(name = "Intervention.findByIdentIntervention", query = "SELECT i FROM Intervention i WHERE i.identIntervention = :identIntervention")})
public class Intervention implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "date_intervention")
    @Temporal(TemporalType.DATE)
    private Date dateIntervention;
    @Column(name = "duree_intervention")
    private Integer dureeIntervention;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "ident_intervention")
    private String identIntervention;
    @ManyToMany(mappedBy = "interventionList")
    private List<Employe> employeList;
    @OneToMany(mappedBy = "identIntervention")
    private List<Pieces> piecesList;
    @OneToMany(mappedBy = "identIntervention")
    private List<InterCons> interConsList;
    @OneToMany(mappedBy = "identIntervention")
    private List<Tache> tacheList;
    @JoinColumn(name = "ident_type", referencedColumnName = "ident_type")
    @ManyToOne
    private TypeIntervention identType;
    
    @JoinColumn(name = "identif", referencedColumnName = "identif")
    @ManyToOne
    private Tache identif;
    
    @JoinColumn(name = "id_machine", referencedColumnName = "id_machine")
    @ManyToOne
    private Machine idMachine;
    @JoinColumn(name = "identifiant_arret", referencedColumnName = "identifiant_arret")
    @ManyToOne
    private ArretMachine identifiantArret;
    @OneToMany(mappedBy = "identIntervention")
    private List<ArretMachine> arretMachineList;

    public Intervention() {
    }

    public Intervention(String identIntervention) {
        this.identIntervention = identIntervention;
    }

    public Date getDateIntervention() {
        return dateIntervention;
    }

    public void setDateIntervention(Date dateIntervention) {
        this.dateIntervention = dateIntervention;
    }

    public Integer getDureeIntervention() {
        return dureeIntervention;
    }

    public void setDureeIntervention(Integer dureeIntervention) {
        this.dureeIntervention = dureeIntervention;
    }

    public String getIdentIntervention() {
        return identIntervention;
    }

    public void setIdentIntervention(String identIntervention) {
        this.identIntervention = identIntervention;
    }

    @XmlTransient
    public List<Employe> getEmployeList() {
        return employeList;
    }

    public void setEmployeList(List<Employe> employeList) {
        this.employeList = employeList;
    }

    @XmlTransient
    public List<Pieces> getPiecesList() {
        return piecesList;
    }

    public void setPiecesList(List<Pieces> piecesList) {
        this.piecesList = piecesList;
    }

    @XmlTransient
    public List<InterCons> getInterConsList() {
        return interConsList;
    }

    public void setInterConsList(List<InterCons> interConsList) {
        this.interConsList = interConsList;
    }

    @XmlTransient
    public List<Tache> getTacheList() {
        return tacheList;
    }

    public void setTacheList(List<Tache> tacheList) {
        this.tacheList = tacheList;
    }

    public TypeIntervention getIdentType() {
        return identType;
    }

    public void setIdentType(TypeIntervention identType) {
        this.identType = identType;
    }

    public Tache getIdentif() {
        return identif;
    }

    public void setIdentif(Tache identif) {
        this.identif = identif;
    }

    public Machine getIdMachine() {
        return idMachine;
    }

    public void setIdMachine(Machine idMachine) {
        this.idMachine = idMachine;
    }

    public ArretMachine getIdentifiantArret() {
        return identifiantArret;
    }

    public void setIdentifiantArret(ArretMachine identifiantArret) {
        this.identifiantArret = identifiantArret;
    }

    @XmlTransient
    public List<ArretMachine> getArretMachineList() {
        return arretMachineList;
    }

    public void setArretMachineList(List<ArretMachine> arretMachineList) {
        this.arretMachineList = arretMachineList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (identIntervention != null ? identIntervention.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Intervention)) {
            return false;
        }
        Intervention other = (Intervention) object;
        if ((this.identIntervention == null && other.identIntervention != null) || (this.identIntervention != null && !this.identIntervention.equals(other.identIntervention))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gmao.entities.Intervention[ identIntervention=" + identIntervention + " ]";
    }
    
}
